<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/content/variable.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<%@ include file="/content/head.jsp"%>
</head>
<body>
    <div class="row">
        <div class="col-md-12">
            <div class="box box-info">
                <div class="box-header with-border">
                    <h3 class="box-title">修改写真视频内容</h3>
                </div>
                <form id="addInfo" class="form-horizontal" role="form" onsubmit="javascript:saveInfo();">
                    <div class="box-body">
                        <div class="form-group">
                            <label for="videoName" class="col-sm-2 control-label">视频名称：</label>
                            <div class="col-sm-8 ">
                                <input type="text" id="videoName" class="form-control" name="videoName" value="${obj.videoName}"
                                       placeholder="视频名称">
                            </div>
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="videoUrl" class="col-sm-2 control-label">视频地址：</label>
                             <div class="col-md-8">
								<input type="file" class="file-loading" id="videoUrlFile" accept="video/*">
								<input type="text" class="form-control input-sm" id="videoUrlUrl" name="videoUrl" value="${obj.videoUrl}"> 
							</div>
							<div class="col-sm-2">
								<span class="help-inline" style="color: #a94442"></span>
							</div>
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="videoCover" class="col-sm-2 control-label">视频封面：</label>
                            <div class="col-md-8">
								<input type="file" class="file-loading" id="videoCoverFile" accept="image/*">
								<input type="text" class="form-control input-sm" id="videoCoverUrl" name="videoCover" value="${obj.videoCover}"> 
							</div>
							<div class="col-sm-2">
								<span class="help-inline" style="color: #a94442"></span>
							</div>
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="videoTime" class="col-sm-2 control-label">视频时长：</label>
                            <div class="col-sm-8 ">
                                <input type="text" id="videoTime" class="form-control" name="videoTime" value="${obj.videoTime}"
                                       placeholder="视频时长">
                            </div>
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="videoDesc" class="col-sm-2 control-label">视频简介：</label>
                            <div class="col-sm-8 ">
                                <input type="text" id="videoDesc" class="form-control" name="videoDesc" value="${obj.videoDesc}"
                                       placeholder="视频简介">
                            </div>
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="videoType" class="col-sm-2 control-label">视频类型：</label>
                            <div class="col-sm-8 ">
                                <input type="text" id="videoType" class="form-control" name="videoType" value="${obj.videoType}"
                                       placeholder="视频类型">
                            </div>
                        </div>
                        <br>
                        <input type="hidden" name ="id" id="id" value="${obj.id}"/>
                        <div class="col-md-offset-5 col-md-9">
                            <button type="submit" class="btn btn-success">确定</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <!-- /.row -->
<%@ include file="/content/js.jsp"%>
<script type="text/javascript">
$(function(){
//封面上传
   $("#videoCoverFile").fileinput({
   	uploadUrl:"<%=path%>/portrait/video/uploadClassifyImg",
       browseClass: "btn btn-primary",
       enctype: 'multipart/form-data',
       autoReplace:true,
       dropZoneEnabled:false,
       browseLabel: "上传",
       showCaption: false,
       showRemove: false,
       showUpload: true,
       showZoom:false,
       maxFileCount:1, ////表示允许同时上传的最大文件个数
       allowedFileTypes:["image"], //文件的选择类型[‘image’, ‘html’, ‘text’, ‘video’, ‘audio’, ‘flash’, ‘object’]
       previewSettings:{
       	image: {width: "auto", height: "100px"},
       },
   });
   $('#videoCoverFile').on('fileuploaded', function(event, data, previewId, index) {
   	var path = data.response.initialPreviewConfig[0].extra.path;
       $("#videoCoverUrl").val(path);
   });
   $('#videoCoverFile').on('filedeleted', function(event,key,jqXHR,data) {
   	if($("#videoCoverUrl").val()==data.path)
   		$("#videoCoverUrl").val('');
   }); 
 //视频上传
 //这里发现fileinput有用一个bug
 //当要上传文件大于50MB左右的时候,如果开启了文件预览则点击上传按钮并不会触发上传事件
 //解决方法：showPreview:false 关闭预览即可上传大于50MB的文件
 //另：根据实际使用，本地测试阿里OSS一般每上传10MB需要约1分钟
   $("#videoUrlFile").fileinput({
   	uploadUrl:"<%=path%>/portrait/video/uploadClassifyVideo",
       browseClass: "btn btn-primary",
       autoReplace:true,
       dropZoneEnabled:false,
       browseLabel: "上传",
       showCaption: false,
       showRemove: false,
       showPreview:false,
       showUpload: true,
       showZoom:false,
       maxFileCount:1, ////表示允许同时上传的最大文件个数
//        allowedFileTypes:["video"], //文件的选择类型[‘image’, ‘html’, ‘text’, ‘video’, ‘audio’, ‘flash’, ‘object’]
       maxFileSize:0,//单位为kb，如果为0表示不限制文件大小
       previewSettings:{
       		type:"video",
    		video: {width: "auto", height: "100px"},
      },
   });
   $('#videoUrlFile').on('fileuploaded', function(event, data, previewId, index) {
   	var path = data.response.initialPreviewConfig[0].extra.path;
       $("#videoUrlUrl").val(path);
       $("#videoUrlUrl").triggerHandler("blur");
   });
   $('#videoUrlFile').on('filedeleted', function(event,key,jqXHR,data) {
   	if($("#videoUrlUrl").val()==data.path)
   		$("#videoUrlUrl").val('');
   	$("#videoUrlUrl").triggerHandler("blur");
   }); 
});

	function saveInfo(){
		var videoCover = $("#videoCoverUrl").val();
		var videoName = $("#videoName").val();
		var videoUrl = $("#videoUrlUrl").val();
		var videoTime = $("#videoTime").val();
		var videoDesc = $("#videoDesc").val();
		var videoType= $("#videoType").val();
		var id= $("#id").val();
		$.ajax({
			type:"post",
			async: false,
			url:"<%=path%>/portrait/video/alertVideoSave",
			data:{videoCover:videoCover,
				videoName:videoName,
				videoUrl:videoUrl,
				videoTime:videoTime,
				videoDesc:videoDesc,
				videoType:videoType,
				id:id},
			dataType:"json",
			success: function(data){
				if (data.missage == "success") {
                    modalMsg("修改成功", "success");
                    window.parent.location.reload();
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }else if(data.missage == "error"){
                	 modalMsg("修改失败", "error");
                }else{
                	 modalMsg("更新失败", "error");
                }
			}
		});
	}
</script>
</body>
</html>